﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Xml.Linq;

namespace devtm.Editor.Configuration.Data
{
    public class TemplateAttributeXml: ConfigProperty
    {


        public TemplateAttributeXml() { }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "sectionInformation")]
        public TemplateAttributeXml(SectionInformation sectionInformation, String name)
        {
            this.SectionInformation = sectionInformation;
            this.DisplayName = name;
                        
        }


        public override void RunEditor()
        {
            throw new NotImplementedException();
        }


        public override void Selector()
        {
            throw new NotImplementedException();
        }
        


        public DefaultSection DefaultSection { get; set; }


        public override Object Value
        {
            get
            {
                return (String)XElement.Parse(SectionInformation.GetRawXml()).Attribute(Name);
            }
            set
            {

                if (Value == value) return;

                XElement xml = XElement.Parse(SectionInformation.GetRawXml());
                xml.Attribute(Name).Value = (String)value;
                String towrite = xml.ToString();
                SectionInformation.SetRawXml(towrite);


                ValueHasChanged();

            }
        }

        public SectionInformation SectionInformation { get; set; }

    }
}
